<!--#include file="common/header.html"-->
<body>
    <div class="container-fluid larry-wrapper">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12">
                <!--头部搜索-->
                <section class="panel panel-padding">
                    <form class="layui-form" action="/education/admin/productComment">
                        <input type="hidden" name="_query.productId" id="queryProductId">
                        <div class="layui-form">
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input class="layui-input" name="_query.keyword" placeholder="关键字">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button lay-submit class="layui-btn" lay-filter="search" id="search">查找</button>
                            </div>
                        </div>
                    </form>
                </section>

                <!--列表-->
                <section class="panel panel-padding">
                    <div class="group-button">
                        <!--<button class="layui-btn layui-btn-small modal-catch"
                                data-params='{"content":".add-subcat", "title":"添加","type":"1", "full":"true", "maxmin":"true"}'>
                            <i class="iconfont">&#xe649;</i> 添加
                        </button>-->
                        <button class="layui-btn layui-btn-small layui-btn-danger ajax-all" data-name="checkbox" data-params='{"url": "/education/admin/productComment/delete"}'>
                            <i class="iconfont">&#xe626;</i> 删除
                        </button>
                    </div>
                    <div id="list" class="layui-form"></div>

                    <div class="text-right" id="page"></div>
                </section>
            </div>
        </div>
    </div>

    <div class="add-subcat">
        <form class="layui-form layui-form-pane" action="/education/admin/productComment/imported" id="form1">
            <input type="hidden" name="id">

            <div class="layui-form-item">
                <label class="layui-form-label">选择文件</label>
                <div class="layui-input-inline">
                    <input class="layui-input" name="file" type="file" required jq-verify="required">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" jq-submit jq-filter="submit">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>

</body>
<script id="list-tpl" type="text/html"
        data-params='{"url":"/education/admin/productComment","dataName":"productCommentData","pageid":"#page", "method":"post"}'>
    <table id="example" class="layui-table lay-even" data-name="productCommentData" data-tplid="list-tpl">
        <thead>
        <tr>
            <th width="30"><input type="checkbox" id="checkall" data-name="checkbox" lay-filter="check"
                                  lay-skin="primary"></th>
            <th>评价内容</th>
            <th width="150">图片</th>
            <th width="160">几颗星</th>
            <th width="120">是否APP显示</th>
            <th width="100">评价人</th>
            <th width="170">评价时间</th>
            <!--<th width="200">操作</th>-->
        </tr>
        </thead>
        <tbody>
        {{# layui.each(d.list, function(index, item){ }}
        <tr>
            <td><input type="checkbox" name="checkbox" value="{{ item.id}}" lay-skin="primary"></td>
            <td>{{ item.comment_content }}</td>
            <td>
                <div class="layer-photos-demo">
                    {{# var imgs = item.comment_images && item.comment_images.split(',')  }}
                    {{# if(imgs) { }}
                    {{# for(var i=0;i< imgs.length; i++){ }}
                    <img layer-src="/education{{ imgs[i] }}"  src="/education{{ imgs[i] }}"
                         onclick="viewImg();"
                         style="height:60px;"  alt="图片">
                    {{# } } }}
                </div>
            </td>
            <td>
                {{# for(var i=1;i<= item.star;i++){ }}
                <i class="iconfont color-yellow" style="font-size: 14px;">&#xe61f;</i>
                {{# } }}
            </td>
            <td><input type="checkbox" name="comment_status" lay-skin="switch" lay-text="显示|隐藏"
                       {{#if (item.comment_status == 1){ }}checked="checked" {{# } }} lay-filter="ajax" value="1"
                       data-params='{"url":"/education/admin/productComment/update/{{ item.id}}","data":"id={{ item.id}}"}'>
            </td>
            <td>{{ item.comment_username||''}}</td>
            <td>{{# if(item.create_time == null){ }} {{#  } else { }} {{ item.create_time}}  {{#  } }}</td>
            <!--<td>
                <button class="layui-btn layui-btn-mini layui-btn-danger ajax"
                        data-list='{"key":"id={{ item.id}}","msg":true,"render":"true","action":"del"}'
                        data-params='{"url": "/education/admin/productComment/delete/{{item.id}}","data":"", "method":"post", "confirm":"true"}'>
                    <i class="iconfont">&#xe626;</i>删除
                </button></td>
            </td>-->
        </tr>
        {{# }); }}
        </tbody>

    </table>
</script>
<script src="../js/layui/layui.js"></script>
<script type="text/javascript" src="../js/lib/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="../js/lib/rest.js"></script>
<script type="text/javascript" src="../../jsfile/jquery/jquery.form.js"></script>
<!--#include file="common/version.html"-->
<script>
    layui.use('user_list');

   /* layui.use(['jquery','upload'], function() {
        var box;
        //上传文件设置
        layui.upload({
            elem: '.layui-upload-file',
            url: '/education/api/image/productComment',
            before: function (input) {
                box = $(input).parent('form').parent('div').parent('.layui-input-block');
                if (box.next('div').length > 0) {
                    box.next('div').html('<div class="imgbox"><p>上传中...</p></div>');
                } else {
                    box.after('<div class="layui-input-block"><div class="imgbox"><p>上传中...</p></div></div>');
                }
            },
            success: function (res) {
                if (res.code == 200) {
                    box.next('div').find('div.imgbox').html('<img src="/education' + res.data[0].url + '" alt="..." class="img-thumbnail">');
                    box.find('input[name=url]').val(res.data[0].url);
                    $('#imgWidth').val(res.data[0].width);
                    $('#imgHeight').val(res.data[0].height);
                } else {
                    box.next('div').find('p').html('上传失败...')
                }
            }
        });
    });*/

    function initData(){
        var $v = '{"url":"/education/admin/productComment?_query.productId='+ getQueryString('ids')
            +'","dataName":"productCommentData","pageid":"#page", "method":"post", "data":"orderColunm=a.id&orderMode=asc"}';
        $("#list-tpl").attr('data-params', $v);
        $('#queryProductId').val(getQueryString('ids'));
    }

    function viewImg() {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.photos({
                photos: '.layer-photos-demo'
                ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
            });
        });
    }

    function beforeAdd(obj){
        $('.imgbox').children().remove();
        $('#form1').attr('action', '/education/admin/productComment/save');
    }

    function submitForm() {
        var pid = getQueryString('ids');
        $('#pid').val(pid);
        restInsert('/education/admin/productComment/save', {}, $('#form1'), function (rs) {
            if(rs.status == 200){
                layer.close(layer.index);
//                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
//                parent.layer.close(index); //再执行关闭
                layer.msg('操作成功');
                $('#search').trigger('click')
            }
        })
    }
</script>

</html>